package com.example.demo.service.sys.impl;

import com.example.demo.bean.sys.SysUser;
import com.example.demo.repository.SysUserMapper;
import com.example.demo.service.exception.ErrorCode;
import com.example.demo.service.exception.ServiceException;
import com.example.demo.service.sys.SysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author zzz
 * @Title: SysUserServiceImpl
 * @ProjectName test
 * @Description: TODO()
 * @date 2018/7/12
 */
@Service
public class SysUserServiceImpl implements SysUserService {

    private final static Logger LOGGER = LoggerFactory.getLogger(SysUserServiceImpl.class);

    @Autowired private SysUserMapper SysUserMapper;

    @Override
    public SysUser login(String account, String passWord) {
        if(StringUtils.isEmpty(account) || StringUtils.isEmpty(passWord)){
            throw  new ServiceException(ErrorCode.NULL_ERROR);
        }
        SysUser sysUser =  SysUserMapper.login(account,passWord);
        if(StringUtils.isEmpty(sysUser)){
            throw  new ServiceException(ErrorCode.PASSWORD_ERROR);
        }
        return sysUser;
    }
}
